package com.fengze.shop.common.config.item;

import com.fengze.shop.common.config.CommonConfig;
import com.fengze.shop.common.config.ConfigDataListener;
import com.fengze.shop.common.config.ModuleConfig;
import com.fengze.shop.common.config.SystemConfig;
import lombok.extern.slf4j.Slf4j;

/**
 * Created by win7 on 2017/3/30 0030.
 */
@Slf4j
public class SimplePwdConfig implements ConfigDataListener {

    private static SimplePwdConfig instance = null;

    private CommonConfig config = null;

    // 简单密码列表
    private String[] pwdList;

    public static SimplePwdConfig getInstance() {
        if (instance == null) {
            instance = new SimplePwdConfig();
        }
        return instance;
    }

    /**
     * 构造函数
     */
    private SimplePwdConfig() {
        SystemConfig.getSystemConfig().addConfigDataListener(this);
        SystemConfig systemConfig = SystemConfig.getSystemConfig();
        ModuleConfig moduleConfig = systemConfig.getModuleConfig("simplePwd");
        config = new CommonConfig(moduleConfig);
        doConfigRefresh();
    }

    public void doConfigRefresh() {
        //获取简单密码列表
        pwdList = config.getArrayValue("simplePwd");
    }

    public String getListenerName() {
        return "simplePwd";
    }

    public String[] getPwdList() {
        return pwdList;
    }

    public void setPwdList(String[] pwdList) {
        this.pwdList = pwdList;
    }

}
